<?php
namespace App\Http\Controllers\Validator;
use Validator;

/**
 * Class RoomInfoVail
 * @package App\Http\Controllers\Validator
 *房源表验证器
 */
class RoomInfoVail{

    public static function validate($params)
    {
        $return = true;
        $validator = Validator::make($params, [
            'building_id'                =>        'required',//楼盘字典id
            'few_building'               =>        'required',//栋座
            'position'                   =>        'required',//位置
            'room_number'                =>        'required',//房号
            'floor'                      =>        'required',//楼层
            'total_layer'                =>        'required',//总层.
            'use_type'                   =>        'required',//用途id
            'housing_types'              =>        'required',//房屋类型（多层，高层，小高层）
            'type_of_house_sale'         =>        'required',//房屋出售类型(普通房，优质房，聚焦房)
            'disc_type'                  =>        'required',//盘类型 （公盘、私盘、特盘、封盘）
            'trading_type'               =>        'required',//交易类型(租，售，租售)
            'owner_name'                 =>        'required',//业主姓名
            'owner_phone'                =>        'required',//业主电话
            'source_uid'                 =>        'required',//用户ID.
            'r_d_id'                     =>        'required', //部门ID.
            'status'                     =>        'required',  //房源有效 预定
            'r_info'                     =>        'required'   //前台根据用途不同填写不同参数的值
        ]);
        if ($validator->fails()) {
            $return = false;
        }
        return $return;
    }

    public static function getWordbookValidate($params){
        $return = true;
        $validator = Validator::make($params, [
//            'p_id'                       =>        'required',//省id
//            'c_id'                       =>        'required',//市id
            'w_spell'                    =>        'required' //楼盘字典首字母简拼或者楼盘的名字
        ]);
        if ($validator->fails()) {
            $return = false;
        }
        return $return;
    }


    /**
     * 查重复房源  验证提交的参数
     */
    public static function check($params){
        $return = true;
        $validator = Validator::make($params, [
            'building_id'                =>        'required',//楼盘字典名称
            'few_building'               =>        'required',//栋座
            'position'                   =>        'required', //位置
            'room_number'                =>        'required' //房号
        ]);
        if ($validator->fails()) {
            $return = false;
        }
        return $return;
    }

    /**删除房源  验证该房源的ID
     * @param $params
     * @return bool
     */
    public static function updateStatus($params){
        $return = true;
        $validator = Validator::make($params, [
            'id'                       =>        'required'//房源ID
        ]);
        if ($validator->fails()) {
            $return = false;
        }
        return $return;
    }

    /**添加 修改房源的时候 验证业主电话是否存在
     * @param $params
     * @return bool
     */
    public static function verificationPhone($params)
    {
        $return = true;
        $validator = Validator::make($params, [
            'owner_phone'     =>        'required'//业主电话
        ]);
        if ($validator->fails()) {
            $return = false;
        }
        return $return;
    }
}